home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Demos / Collision][ demo ƒ / Collision][.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  2KB  |  75 lines

  1. /********************************/
  2. /********** SAT Collision ][ ***********/
  3. /********************************/
  4.  
  5. /*A more advanced version of SAT Collision, demonstrating the use of callback routines*/
  6. /*(hit task) for collision handling. What has happened is that the apples switch between*/
  7. /*good and bad, and we are not supposed to eat one when it's bad.*/
  8.  
  9. /*program CollisionII;*/
  10.  
  11. #include "SAT.h"
  12. #include "Collision][.h"
  13.  
  14.  
  15.  
  16. main()
  17. {
  18.     SpritePtr    ignoreSp;
  19.     long        l;
  20.     Point        p;
  21.     int ignore;
  22.     Rect gameArea; // temp debug
  23.  
  24. /*Standard Inits.*/
  25.     MaxApplZone ();
  26.     FlushEvents (everyEvent - diskMask, 0 );
  27. #ifdef THINK_C
  28.     InitGraf (&thePort);
  29. #else
  30.     InitGraf (&qd.thePort);
  31. #endif
  32.     InitFonts ();
  33.     InitWindows ();
  34.     InitMenus ();
  35.     TEInit ();
  36.     InitDialogs (nil);        /* no restart proc */
  37.     InitCursor ();
  38.  
  39.     MoreMasters ();
  40.     MoreMasters ();
  41.  
  42.  
  43.     SATConfigure(true, kVPositionSort, kBackwardCollision, 32);
  44.     SATInit(128, 129, 512, 322);
  45.  
  46. //    SetRect(&gameArea, 0, 0, 512, 342);
  47. //    SATCustomInit(128, 129, &gameArea, nil, nil, false, true, true, true, true);
  48. //    ShowWindow(gSAT.wind.port);
  49. //    SATRedraw();
  50.  
  51.     InitMrEgghead();
  52.     InitApple();
  53.  
  54.     GetMouse(&p);
  55.     ignoreSp = SATNewSprite(0, p.h, p.v, &SetupMrEgghead);
  56.     ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
  57.  
  58.     HideCursor();
  59.  
  60. /* Get two channels if possible, since we use fairy long sounds. */
  61.     ignore = SATSoundInitChannels(2);
  62.  
  63.     while (!Button()) {
  64.         l = TickCount();
  65.         SATRun(true);
  66. /*Start a new sprite once in a while.*/
  67.         if (SATRand(40) == 1)
  68.             ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
  69.         while (l > TickCount() - 2L) /*Maximize speed to 30 fps*/
  70.             ;
  71.     };
  72.     ShowCursor();
  73.     FlushEvents(mDownMask, 0); //Flush the mouse click, so we won't click randomly in the Finder!
  74.     SATSoundShutup(); /*Always make sure the sound channel is de-allocated!*/
  75. }